<?php

if (!defined('IN_ADMIN')) {
    exit('Access Denied');
}

$mpurl	 			= 'admin.php?ac=count_push';

if ( $_GET['op'] == 'setJpush')/*{{{*/
{
	$param['uid']			=	strval($_GET['uid']);
	$param['jpush']			=	strval($_GET['jpush']);
	$param['disturb']		=	strval($_GET['disturb']);
	$param['comment']		=	strval($_GET['comment']);
	$param['message']		=	strval($_GET['message']);
	$param['follow']		=	strval($_GET['follow']);
	$param['upstart']		=	strval($_GET['upstart']);
	$param['upend']			=	strval($_GET['upend']);
	
	$param['do']		=	'setJpush';
	$param['format']	=	'json';
	$content  =  get_api_content($_SC ['apiurl'], $param);
	$content  =  json_decode($content);
	
	$resetResult = '';
	if ($content->resultData == 1) {
	
		$resetResult = '操作成功';
	
		$msg = "操作成功!";
		cpmessage($msg);
	}
	$msg = "操作失败，请重试一次!";
	if ($content->errorNo) {
		$resetResult = '操作失败，请重试一次';
	
		$msg .= "errorNo:" . $content->errorNo;
	}
	cpmessage($msg);
}elseif($_GET['op'] == 'addJpush')
{
	$param['uid']			=	strval($_GET['uid']);
	$param['jpush']			=	strval($_GET['jpush']);
	$param['disturb']		=	strval($_GET['disturb']);
	$param['comment']		=	strval($_GET['comment']);
	$param['message']		=	strval($_GET['message']);
	$param['follow']		=	strval($_GET['follow']);
	$param['upstart']		=	strval($_GET['upstart']);
	$param['upend']			=	strval($_GET['upend']);
	
	$param['do']		=	'addJpush';
	$param['format']	=	'json';
	$content  =  get_api_content($_SC ['apiurl'], $param);
	$content  =  json_decode($content);
	
	$resetResult = '';
	if ($content->resultData == 1) {
	
		$resetResult = '操作成功';
	
		$msg = "操作成功!";
		cpmessage($msg);
	}
	$msg = "操作失败，请重试一次!";
	if ($content->errorNo) {
		$resetResult = '操作失败，请重试一次';
	
		$msg .= "errorNo:" . $content->errorNo;
	}
	cpmessage($msg);
}else{
// 	function array_random_assoc($arr, $num = 1) {
// 		$keys = array_keys($arr);
// 		shuffle($keys);
	
// 		$r = array();
// 		for ($i = 0; $i < $num; $i++) {
// 			$r[$keys[$i]] = $arr[$keys[$i]];
// 		}
// 		return $r;
// 	}
	
// 	$a = array("apple",  "banana","cherry", "cherry1","cherry2", "cherry3");
// 	$bb = array_random_assoc($a,3);
// 	echo '<pre>';var_dump($bb);exit;
	$param['do']		=	'getPushInfo';
	$param['format']	=	'json';
	$param['uid']		=	'3894301';
	$content  =  get_api_content($_SC ['apiurl'], $param);
	$content  =  json_decode($content);
	$result =  object_to_array($content->resultData);
}